<template>
  <div class="userInfo">
    <van-image
      round
      width="8rem"
      height="8rem"
      :src="user.avatar"
      style="margin:0 auto;display:block;"
    />
    <van-cell-group>
      <van-cell  title="昵称" :value="user.nick" readonly />
      <van-cell  title="状态" value="在线" readonly />
      <van-cell  title="邮箱" :value="user.email" readonly />
      <van-cell  title="最后登录IP" :value="user.lastLoginIp" readonly />
      <van-cell  title="手机号" :value="user.mobile" readonly />
      <van-cell v-if="user.vip"  title="VIP级别" :value="user.vip.name" readonly />
      <van-cell  else title="VIP级别" value="无" readonly />
    </van-cell-group>
  </div>
</template>

<script>
import {getUserInfo} from '@/api/user'
export default {
  data() {
    return {
      user:{}
    }
  },
  created(){
    this.getUser()
  },
  methods: {
    async getUser() {
      await getUserInfo().then(response=>{
        if (response.code === '200') {
          this.user = response.data
        }
      })
    }
  }
}
</script>

<style>

</style>